package com.beyond.pratice.dao;

import org.hibernate.criterion.Criterion;

import java.util.List;
import java.io.Serializable;

/**
 * 定义如果支持Entity不被直接删除必须支持的Operation.
 * 
 */
public interface UndeleteableEntityOperation<T> {
	/**
	 * The value indicated object was deleted.
	 */
	Boolean UNVALID_VALUE = true;

	/**
	 * The value indicated object was not deleted.
	 */
	Boolean NORMAL_VALUE = false;

	/**
	 * The name of object's propertie for "is_deleted" flag.
	 */
	String STATUS = "deleted";

    /**
     * 获取状态为有效的对象
     */
    T getValid(Serializable id);

    /**
	 * 取得所有状态为有效的对象.
	 */
	List<T> getAllValid();

	/**
	 * 删除对象，但如果是Undeleteable的entity,设置对象的状态而不是直接删除.
	 */
	void remove(Object entity);

	/**
	 * 获取过滤已删除对象的hql条件语句.
	 */
	String getUnDeletableHQL();

	/**
	 * 获取过滤已删除对象的Criterion条件语句.
	 */
	Criterion getUnDeletableCriterion();
}
